import { ElButton, ElText } from 'element-plus';

const initEditorConfig = () => {
  const componentList = [];
  const componentMap = {};
  return {
    componentList,
    componentMap,
    register: (component) => {
      componentList.push(component);
      componentMap[component.name] = component;
    },
  };
};
const editorConfig = initEditorConfig();
editorConfig.register({
  name: 'button',
  label: '按钮',
  imageUrl: require('@/assets/images/componentsImages/button.png'),
  config: {
    props: {
      content: '按钮',
      size: 'default',
      type: 'default',
      text: false,
      round: false,
      circle: false,
      loading: false,
      disabled: false,
    },
  },
  render: (config) => {
    const { props } = config;
    return <ElButton {...props}>{props.content}</ElButton>;
  },
});
editorConfig.register({
  name: 'text',
  label: '文本',
  imageUrl: require('@/assets/images/componentsImages/text.svg'),
  config: {
    props: {
      content: '文本文本',
      type: 'info',
      size: 'default',
      truncated: false, //显示单行省略号
      lineClamp: undefined, //最大行数
      tag: 'span', //自定义元素标签
    },
  },
  render: (config) => {
    const { props } = config;
    return <ElText {...props}>{props.content}</ElText>;
  },
});
export { editorConfig };
